$.Edit = {};
$.Edit.MultipleSelectPair = $({
	__init: function (selects) {
		var source = selects[0], target = selects[1];
		function cloneOption(option) {
			var ret = document.createElement('OPTION');
			ret.text = option.text;
			ret.value = option.value;
			return ret;	
		};
		function moveOption(step) {
			var index = target.selectedIndex, length = target.options.length, insertIndex = index + step;
			if(index == -1 || insertIndex < 0 || insertIndex > length - 1) return false;
			var option = cloneOption(target.options[index]);
			target.options.remove(index);
			target.options.add(option, insertIndex);
			return true;
		};
		this.down = function () {
			return moveOption(-1);
		};
		this.up = function () {
			return moveOption(1);
		};
		this.add = function () {
			$('option[selected=true]', source).each(function(option){
				var nOption = cloneOption(option);
				option.selected = false;
				nOption.selected = true;
				target.options.add(nOption);
			});
		};
		this.remove = function () {
			$('option[selected=true]', target).each(function(option){
				target.removeChild(option);		
			});	
		};
		this.bind = function (buttons) {
			
		};
	}
});